package com.company;

import java.util.HashMap;
import java.util.Map;

public class Topic01 {
    int [] towSum(int[] nums,int target) {
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0;i< nums.length;i++){
            int c = target - nums[i];
            if(map.containsKey(c)){
                return new int[] {map.get(c),i};
            }
            map.put(nums[i],i);
        }
        throw new IllegalArgumentException("没有两个和解!");
    }

}
